from pprint import pprint

import requests
import execjs
page = 40
url = "https://www.zhihu.com/api/v4/search_v3?t=general&q=%E6%9D%8E%E4%BA%91%E8%BF%AA&correction=1&offset={}&limit=20&filter_fields=&lc_idx={}&show_all_topics=0&search_hash_id=e38657ef08d35fd4e4c109dab5604ec2&vertical_info=0%2C1%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C1".format(page,page)
print(url)

with open('x-zse-96.js', 'r', encoding='utf-8') as f:
    js_code = f.read()
ctx = execjs.compile(js_code)
result = ctx.call('xZse96', url.split('com/')[-1])
print(result)
headers = {
  'authority': 'www.zhihu.com',
  'pragma': 'no-cache',
  'cache-control': 'no-cache',
  'x-zse-93': '101_3_2.0',
  'x-ab-param': 'se_ffzx_jushen1=0;pf_noti_entry_num=0;qap_question_visitor= 0;zr_slotpaidexp=1;tp_topic_style=0;tp_contents=2;pf_adjust=0;tp_zrec=0;top_test_4_liguangyi=1;qap_question_author=0;zr_expslotpaid=1;tp_dingyue_video=0',
  'x-ab-pb': 'CsYBuQJQA4AFNAxAATME7Ao7Au0FQgSyBdcLBwzkChsA9gLzAxIFnwI3BTIDRQQUBVILYAvYAjIFQwXCBeMFCwSMBBUFzwtDAIQC1wL0A1cEKgNyA+ALxwKhAwoEsQU/AKIDEQVWBYkMtwN1BOMEfQIpBbQANASNBGkBngXYBTcMtApqAVIFDwugA9wL+AOmBNoEUQWbC0cAjAL0CwELtQvgBMwCVwNVBWQEwQTWBOkEygV0AU8DfwVWDMoCGQUzBT8F0QQOBecFEmMLAAAAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAALGAAAAAABAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAgAAAAADAAAAAAAAAAAAAAAAAQAAAAAAAAA=',
  'x-api-version': '3.0.91',
  'x-zst-81': '3_2.0aR_sn77yn6O92wOB8hPZnQr0EMYxc4f18wNBUgpTrMtuSRFqK6P0E69y-LS9-hp1DufI-we8gGHPgJO1xuPZ0GxCTJHR7820XM20cLRGDJXfgGCBxupMuD_Ie8FL7AtqM6O1VDQyQ6nxrRPCHukMoCXBEgOsiRP0XL2ZUBXmDDV9qhnyTXFMnXcTF_ntRueTh7LqaUCO68pxWDxBYHg92QXGeg3O2Tc8ivLySqgfVG39Iuc0HwpOpDwKVuCPv0N96COyoGH90DH9rLSMYCofsU9_cqtmBw2qRJOOVGL1eBgVxG20QBgLJTOOfrefkXX17ugK9JVMtrxfkHwOuCNLc9LMYwe8DUpMQGYC2D39eAx1CJxm4qfzBrNLg9oKECXY7rxKph9KcJLG2MLMB8LOAUL1AgCsJcO0A939oH9OLBcuTgg_8hS0uhHf0ho19wo_xwSGFho1ghLBJhoLWgLmQvUOoLCOz9XyuhLCQQOC',
  'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36',
  'sec-ch-ua-mobile': '?0',
  'x-requested-with': 'fetch',
  'x-zse-96': result,
  'x-app-za': 'OS=Web',
  'sec-ch-ua': '"Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"',
  'sec-ch-ua-platform': '"Windows"',
  'accept': '*/*',
  'sec-fetch-site': 'same-origin',
  'sec-fetch-mode': 'cors',
  'sec-fetch-dest': 'empty',
  'referer': 'https://www.zhihu.com/search?type=content&q=%E6%9D%8E%E4%BA%91%E8%BF%AA',
  'accept-language': 'zh,zh-CN;q=0.9',
  }
  cookies = {
	'cookie': 'yourcookies'
  
  }

response = requests.get(url, headers=headers)

pprint(response.json())
